﻿
@{
	ViewBag.Title = "Surgery";
	Layout = "~/Views/Shared/_Index.cshtml";
}

<div class="topPanel">
	@Html.Partial("_OrganizeIdDDLToolbarSearchView")
	<div class="toolbar">
		<div class="btn-group">
			<a id="NF-add" authorize="yes" class="btn btn-primary" onclick="btn_add()"><i class="fa fa-plus"></i>新建</a>
		</div>
		<div class="btn-group">
			<a id="NF-edit" class="btn btn-primary" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>修改</a>
		</div>
	</div>
	<div class="search">
		<table>
			<tr>
				<td>
					<div class="input-group">
						<input id="txt_keyword" type="text" class="form-control" placeholder="名称/编码/首拼" style="width: 180px;">
						<span class="input-group-btn">
							<button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
						</span>
					</div>
				</td>
			</tr>
		</table>
	</div>
</div>
<div class="gridPanel">
	<table id="gridList"></table>
	<div id="gridPager"></div>
</div>

<script>
    $(function () {
        initControl();
        gridList()
    })
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            postData: { keyword: $("#txt_keyword").val(), organizeId: $("#OrganizeId").val() },
			url: "/SysDiagnosis/SurgeryGetGridJson",
            height: $(window).height() - 128,
            colModel: [
				{ label: "主键", name: "id", hidden: true, key: true },
				{ label: "国临版编码", name: "ssm", width: 70, align: 'left' },
                { label: '国临版名称', name: 'ssmc', width: 150, align: 'left' },
				{ label: '医保版手术名称', name: 'ssmc_yb', width: 150, align: 'left' },
				{ label: '医保版手术码', name: 'ssm_yb', width: 70, align: 'left' },
                { label: "手术级别", name: "ssjb", width: 100, align: 'left' },
				{
					label: '手术类型', name: 'sslx', width: 80, align: 'left'
					, formatter: function (cellVallue) {
						return cellVallue == 0 ? "诊断型" : (cellVallue == 1 ? "治疗型" : (cellVallue == 2 ? "操作型" : (cellVallue == 3 ? "手术" : "" )));
					}
				},
				{ label: '拼音码', name: 'pym', width: 60, align: 'left' },
                { label: "有效", name: "zt", width: 60, align: "left", formatter: function (cellvalue) { return cellvalue == true ? "<i class=\"fa fa-toggle-on\"></i>" : "<i class=\"fa fa-toggle-off\"></i>"; } },
            ],
            pager: "#gridPager",
            sortname: 'CreateTime desc',
            viewrecords: true
        });
        $("#btn_search").click(function () {
            $("#gridList").jqGrid('setGridParam', {
                postData: { keyword: $("#txt_keyword").val(), organizeId: $("#OrganizeId").val() },
            }).trigger('reloadGrid');
        });
    }

    //回车事件
    $('#txt_keyword').keydownEnterEvent(function () {
        $('#btn_search').trigger('click');
    })

    function initControl() {

    }

    function btn_add() {
        $.modalOpen({
            id: "Form",
            title: "新增手术",
			url: "/SysDiagnosis/SurgeryFrom?orgId=" + $('#OrganizeId').val(),
            width: "550px",
            height: "570px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }

	function btn_edit() {
		debugger
        var seleRowid = jQuery("#gridList").jqGrid("getGridParam", "selrow");
        if (!(seleRowid)) {
            $.modalAlert("请选中一条信息", 'warning');
            return;
        }
        var keyValue = $("#gridList").jqGridRowValue().id;
        $.modalOpen({
            id: "Form",
            title: "修改手术",
			url: "/SysDiagnosis/SurgeryFrom?keyValue=" + keyValue,
            width: "550px",
            height: "570px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }

</script>

